package com.ruoyi.pv.domain;

import cn.hutool.json.JSONUtil;
import com.doudou.core.container.ListUtil;
import com.ruoyi.cert.domain.Cert;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.ex.domain.ExStudyReload;
import lombok.*;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 学员报名记录对象 pv_student_record
 *
 * @author zzx
 * @date 2023-04-20
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@ToString
public class PvStudentRecord extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    private Long id;

    /**
     * 学生编号
     */
    private Long stuId;
    private SysUser student;

    /**
     * 证书编号
     */
    @Excel(name = "证书编号")
    private Long certId;
    private Cert cert;

    /**
     * 班级编号
     */
    @NotNull(message = "班级编号不可为空")
    private Long training;
    @Excel(name = "班级")
    private String trainingName;
    private PvTrainingClass trainingClass;

    /**
     * 评分表
     */
    private List<Integer> childrenScore;
    private List<Integer> puerperaScore;
    private Integer childrenTotalPoints;
    private Integer puerperaTotalPoints;
    private Integer scoreTotal;

    /**
     * 备注
     */
    private String childrenComment;
    private String puerperaComment;

    /**
     * 状态
     */
    @Excel(name = "状态",dictType = "pv_study_record_status")
    private Integer status;

    /**
     * 预留字段1
     */
    private String reservedOne;

    /**
     * 预留字段2
     */
    private String reservedTwo;

    /**
     * 今年的考试记录
     */
    private ExStudyReload exStudyReload;

    public void setChildrenScore(String childrenScore) {
        List<Integer> list = JSONUtil.toList(childrenScore, Integer.class);
        this.childrenScore = list;
        this.childrenTotalPoints = ListUtil.sumInt(list);
    }

    public void setPuerperaScore(String puerperaScore) {
        List<Integer> list = JSONUtil.toList(puerperaScore, Integer.class);
        this.puerperaScore = list;
        this.puerperaTotalPoints = ListUtil.sumInt(list);
    }

    public String getChildrenScore() {
        return this.childrenScore == null ? null :  this.childrenScore.toString();
    }

    public String getPuerperaScore() {
        return this.puerperaScore == null ? null : this.puerperaScore.toString();
    }

    public List<Integer> getChildrenScoreList() {
        return this.childrenScore;
    }

    public List<Integer> getPuerperaScoreList() {
        return this.puerperaScore;
    }
}
